<!DOCTYPE html><html><head><meta charset="utf-8"><style>body {
  max-width: 980px;
  border: 1px solid #ddd;
  outline: 1300px solid #fff;
  margin: 16px auto;
}

body .markdown-body
{
  padding: 45px;
}

@font-face {
  font-family: fontawesome-mini;
  src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAzUABAAAAAAFNgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABbAAAABwAAAAcZMzaOEdERUYAAAGIAAAAHQAAACAAOQAET1MvMgAAAagAAAA+AAAAYHqhde9jbWFwAAAB6AAAAFIAAAFa4azkLWN2dCAAAAI8AAAAKAAAACgFgwioZnBnbQAAAmQAAAGxAAACZVO0L6dnYXNwAAAEGAAAAAgAAAAIAAAAEGdseWYAAAQgAAAFDgAACMz7eroHaGVhZAAACTAAAAAwAAAANgWEOEloaGVhAAAJYAAAAB0AAAAkDGEGa2htdHgAAAmAAAAAEwAAADBEgAAQbG9jYQAACZQAAAAaAAAAGgsICJBtYXhwAAAJsAAAACAAAAAgASgBD25hbWUAAAnQAAACZwAABOD4no+3cG9zdAAADDgAAABsAAAAmF+yXM9wcmVwAAAMpAAAAC4AAAAusPIrFAAAAAEAAAAAyYlvMQAAAADLVHQgAAAAAM/u9uZ4nGNgZGBg4ANiCQYQYGJgBEJuIGYB8xgABMMAPgAAAHicY2Bm42OcwMDKwMLSw2LMwMDQBqGZihmiwHycoKCyqJjB4YPDh4NsDP+BfNb3DIuAFCOSEgUGRgAKDgt4AAB4nGNgYGBmgGAZBkYGEAgB8hjBfBYGCyDNxcDBwMTA9MHhQ9SHrA8H//9nYACyQyFs/sP86/kX8HtB9UIBIxsDXICRCUgwMaACRoZhDwA3fxKSAAAAAAHyAHABJQB/AIEAdAFGAOsBIwC/ALgAxACGAGYAugBNACcA/wCIeJxdUbtOW0EQ3Q0PA4HE2CA52hSzmZDGe6EFCcTVjWJkO4XlCGk3cpGLcQEfQIFEDdqvGaChpEibBiEXSHxCPiESM2uIojQ7O7NzzpkzS8qR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WZfgF0r/zJQB4nG2JUQuCQBCEd07TTg36fb2IyBaLd3vWaUh/vmSJnvpgmG8YcmS8X3Shf3R7QA4OBUocUKHGER5NNbOOEvwc1txnuWkTRb/aPjimJ5vXabI+3VfOiyS15UWvyezM2xiGOPyuMohOH8O8JiO4Af+FsAGNAEuwCFBYsQEBjlmxRgYrWCGwEFlLsBRSWCGwgFkdsAYrXFhZsBQrAAA=) format('woff');
}

@font-face {
  font-family: octicons-anchor;
  src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAYcAA0AAAAACjQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABMAAAABwAAAAca8vGTk9TLzIAAAFMAAAARAAAAFZG1VHVY21hcAAAAZAAAAA+AAABQgAP9AdjdnQgAAAB0AAAAAQAAAAEACICiGdhc3AAAAHUAAAACAAAAAj//wADZ2x5ZgAAAdwAAADRAAABEKyikaNoZWFkAAACsAAAAC0AAAA2AtXoA2hoZWEAAALgAAAAHAAAACQHngNFaG10eAAAAvwAAAAQAAAAEAwAACJsb2NhAAADDAAAAAoAAAAKALIAVG1heHAAAAMYAAAAHwAAACABEAB2bmFtZQAAAzgAAALBAAAFu3I9x/Nwb3N0AAAF/AAAAB0AAAAvaoFvbwAAAAEAAAAAzBdyYwAAAADP2IQvAAAAAM/bz7t4nGNgZGFgnMDAysDB1Ml0hoGBoR9CM75mMGLkYGBgYmBlZsAKAtJcUxgcPsR8iGF2+O/AEMPsznAYKMwIkgMA5REMOXicY2BgYGaAYBkGRgYQsAHyGMF8FgYFIM0ChED+h5j//yEk/3KoSgZGNgYYk4GRCUgwMaACRoZhDwCs7QgGAAAAIgKIAAAAAf//AAJ4nHWMMQrCQBBF/0zWrCCIKUQsTDCL2EXMohYGSSmorScInsRGL2DOYJe0Ntp7BK+gJ1BxF1stZvjz/v8DRghQzEc4kIgKwiAppcA9LtzKLSkdNhKFY3HF4lK69ExKslx7Xa+vPRVS43G98vG1DnkDMIBUgFN0MDXflU8tbaZO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1s1xHzTXRqgKzek/mb7nB8RZTCDhGEX3kK/8Q75AmUM/eLkfA+0Hi908Kx4eNsMgudg5GLdRD7a84npi+YxNr5i5KIbW5izXas7cHXIMAau1OueZhfj+cOcP3P8MNIWLyYOBuxL6DRylJ4cAAAB4nGNgYoAALjDJyIAOWMCiTIxMLDmZedkABtIBygAAAA==) format('woff');
}

.markdown-body {
  font-family: sans-serif;
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  color: #333333;
  overflow: hidden;
  font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  word-wrap: break-word;
}

.markdown-body a {
  background: transparent;
}

.markdown-body a:active,
.markdown-body a:hover {
  outline: 0;
}

.markdown-body b,
.markdown-body strong {
  font-weight: bold;
}

.markdown-body mark {
  background: #ff0;
  color: #000;
  font-style: italic;
  font-weight: bold;
}

.markdown-body sub,
.markdown-body sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}
.markdown-body sup {
  top: -0.5em;
}
.markdown-body sub {
  bottom: -0.25em;
}

.markdown-body h1 {
  font-size: 2em;
  margin: 0.67em 0;
}

.markdown-body img {
  border: 0;
}

.markdown-body hr {
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  height: 0;
}

.markdown-body pre {
  overflow: auto;
}

.markdown-body code,
.markdown-body kbd,
.markdown-body pre,
.markdown-body samp {
  font-family: monospace, monospace;
  font-size: 1em;
}

.markdown-body input {
  color: inherit;
  font: inherit;
  margin: 0;
}

.markdown-body html input[disabled] {
  cursor: default;
}

.markdown-body input {
  line-height: normal;
}

.markdown-body input[type="checkbox"] {
  box-sizing: border-box;
  padding: 0;
}

.markdown-body table {
  border-collapse: collapse;
  border-spacing: 0;
}

.markdown-body td,
.markdown-body th {
  padding: 0;
}

.markdown-body .codehilitetable {
  border: 0;
  border-spacing: 0;
}

.markdown-body .codehilitetable tr {
  border: 0;
}

.markdown-body .codehilitetable pre,
.markdown-body .codehilitetable div.codehilite {
  margin: 0;
}

.markdown-body .linenos,
.markdown-body .code,
.markdown-body .codehilitetable td {
  border: 0;
  padding: 0;
}

.markdown-body td:not(.linenos) .linenodiv {
  padding: 0 !important;
}

.markdown-body .code {
  width: 100%;
}

.markdown-body .linenos div pre,
.markdown-body .linenodiv pre,
.markdown-body .linenodiv {
  border: 0;
  -webkit-border-radius: 0;
  -moz-border-radius: 0;
  border-radius: 0;
  -webkit-border-top-left-radius: 3px;
  -webkit-border-bottom-left-radius: 3px;
  -moz-border-radius-topleft: 3px;
  -moz-border-radius-bottomleft: 3px;
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
}

.markdown-body .code div pre,
.markdown-body .code div {
  border: 0;
  -webkit-border-radius: 0;
  -moz-border-radius: 0;
  border-radius: 0;
  -webkit-border-top-right-radius: 3px;
  -webkit-border-bottom-right-radius: 3px;
  -moz-border-radius-topright: 3px;
  -moz-border-radius-bottomright: 3px;
  border-top-right-radius: 3px;
  border-bottom-right-radius: 3px;
}

.markdown-body * {
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

.markdown-body input {
  font: 13px Helvetica, arial, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.4;
}

.markdown-body a {
  color: #4183c4;
  text-decoration: none;
}

.markdown-body a:hover,
.markdown-body a:focus,
.markdown-body a:active {
  text-decoration: underline;
}

.markdown-body hr {
  height: 0;
  margin: 15px 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #ddd;
}

.markdown-body hr:before,
.markdown-body hr:after {
  display: table;
  content: " ";
}

.markdown-body hr:after {
  clear: both;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin-top: 15px;
  margin-bottom: 15px;
  line-height: 1.1;
}

.markdown-body h1 {
  font-size: 30px;
}

.markdown-body h2 {
  font-size: 21px;
}

.markdown-body h3 {
  font-size: 16px;
}

.markdown-body h4 {
  font-size: 14px;
}

.markdown-body h5 {
  font-size: 12px;
}

.markdown-body h6 {
  font-size: 11px;
}

.markdown-body blockquote {
  margin: 0;
}

.markdown-body ul,
.markdown-body ol {
  padding: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.markdown-body ol ol,
.markdown-body ul ol {
  list-style-type: lower-roman;
}

.markdown-body ul ul ol,
.markdown-body ul ol ol,
.markdown-body ol ul ol,
.markdown-body ol ol ol {
  list-style-type: lower-alpha;
}

.markdown-body dd {
  margin-left: 0;
}

.markdown-body code,
.markdown-body pre,
.markdown-body samp {
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: 12px;
}

.markdown-body pre {
  margin-top: 0;
  margin-bottom: 0;
}

.markdown-body kbd {
  background-color: #e7e7e7;
  background-image: -moz-linear-gradient(#fefefe, #e7e7e7);
  background-image: -webkit-linear-gradient(#fefefe, #e7e7e7);
  background-image: linear-gradient(#fefefe, #e7e7e7);
  background-repeat: repeat-x;
  border-radius: 2px;
  border: 1px solid #cfcfcf;
  color: #000;
  padding: 3px 5px;
  line-height: 10px;
  font: 11px Consolas, "Liberation Mono", Menlo, Courier, monospace;
  display: inline-block;
}

.markdown-body>*:first-child {
  margin-top: 0 !important;
}

.markdown-body>*:last-child {
  margin-bottom: 0 !important;
}

.markdown-body .headeranchor-link {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: block;
  padding-right: 6px;
  padding-left: 30px;
  margin-left: -30px;
}

.markdown-body .headeranchor-link:focus {
  outline: none;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  position: relative;
  margin-top: 1em;
  margin-bottom: 16px;
  font-weight: bold;
  line-height: 1.4;
}

.markdown-body h1 .headeranchor,
.markdown-body h2 .headeranchor,
.markdown-body h3 .headeranchor,
.markdown-body h4 .headeranchor,
.markdown-body h5 .headeranchor,
.markdown-body h6 .headeranchor {
  display: none;
  color: #000;
  vertical-align: middle;
}

.markdown-body h1:hover .headeranchor-link,
.markdown-body h2:hover .headeranchor-link,
.markdown-body h3:hover .headeranchor-link,
.markdown-body h4:hover .headeranchor-link,
.markdown-body h5:hover .headeranchor-link,
.markdown-body h6:hover .headeranchor-link {
  height: 1em;
  padding-left: 8px;
  margin-left: -30px;
  line-height: 1;
  text-decoration: none;
}

.markdown-body h1:hover .headeranchor-link .headeranchor,
.markdown-body h2:hover .headeranchor-link .headeranchor,
.markdown-body h3:hover .headeranchor-link .headeranchor,
.markdown-body h4:hover .headeranchor-link .headeranchor,
.markdown-body h5:hover .headeranchor-link .headeranchor,
.markdown-body h6:hover .headeranchor-link .headeranchor {
  display: inline-block;
}

.markdown-body h1 {
  padding-bottom: 0.3em;
  font-size: 2.25em;
  line-height: 1.2;
  border-bottom: 1px solid #eee;
}

.markdown-body h2 {
  padding-bottom: 0.3em;
  font-size: 1.75em;
  line-height: 1.225;
  border-bottom: 1px solid #eee;
}

.markdown-body h3 {
  font-size: 1.5em;
  line-height: 1.43;
}

.markdown-body h4 {
  font-size: 1.25em;
}

.markdown-body h5 {
  font-size: 1em;
}

.markdown-body h6 {
  font-size: 1em;
  color: #777;
}

.markdown-body p,
.markdown-body blockquote,
.markdown-body ul,
.markdown-body ol,
.markdown-body dl,
.markdown-body table,
.markdown-body pre,
.markdown-body .admonition {
  margin-top: 0;
  margin-bottom: 16px;
}

.markdown-body hr {
  height: 4px;
  padding: 0;
  margin: 16px 0;
  background-color: #e7e7e7;
  border: 0 none;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 2em;
}

.markdown-body ul ul,
.markdown-body ul ol,
.markdown-body ol ol,
.markdown-body ol ul {
  margin-top: 0;
  margin-bottom: 0;
}

.markdown-body li>p {
  margin-top: 16px;
}

.markdown-body dl {
  padding: 0;
}

.markdown-body dl dt {
  padding: 0;
  margin-top: 16px;
  font-size: 1em;
  font-style: italic;
  font-weight: bold;
}

.markdown-body dl dd {
  padding: 0 16px;
  margin-bottom: 16px;
}

.markdown-body blockquote {
  padding: 0 15px;
  color: #777;
  border-left: 4px solid #ddd;
}

.markdown-body blockquote>:first-child {
  margin-top: 0;
}

.markdown-body blockquote>:last-child {
  margin-bottom: 0;
}

.markdown-body table {
  display: block;
  width: 100%;
  overflow: auto;
  word-break: normal;
  word-break: keep-all;
}

.markdown-body table th {
  font-weight: bold;
}

.markdown-body table th,
.markdown-body table td {
  padding: 6px 13px;
  border: 1px solid #ddd;
}

.markdown-body table tr {
  background-color: #fff;
  border-top: 1px solid #ccc;
}

.markdown-body table tr:nth-child(2n) {
  background-color: #f8f8f8;
}

.markdown-body img {
  max-width: 100%;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

.markdown-body code,
.markdown-body samp {
  padding: 0;
  padding-top: 0.2em;
  padding-bottom: 0.2em;
  margin: 0;
  font-size: 85%;
  background-color: rgba(0,0,0,0.04);
  border-radius: 3px;
}

.markdown-body code:before,
.markdown-body code:after {
  letter-spacing: -0.2em;
  content: "\00a0";
}

.markdown-body pre>code {
  padding: 0;
  margin: 0;
  font-size: 100%;
  word-break: normal;
  white-space: pre;
  background: transparent;
  border: 0;
}

.markdown-body .codehilite {
  margin-bottom: 16px;
}

.markdown-body .codehilite pre,
.markdown-body pre {
  padding: 16px;
  overflow: auto;
  font-size: 85%;
  line-height: 1.45;
  background-color: #f7f7f7;
  border-radius: 3px;
}

.markdown-body .codehilite pre {
  margin-bottom: 0;
  word-break: normal;
}

.markdown-body pre {
  word-wrap: normal;
}

.markdown-body pre code {
  display: inline;
  max-width: initial;
  padding: 0;
  margin: 0;
  overflow: initial;
  line-height: inherit;
  word-wrap: normal;
  background-color: transparent;
  border: 0;
}

.markdown-body pre code:before,
.markdown-body pre code:after {
  content: normal;
}

/* Admonition */
.markdown-body .admonition {
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  position: relative;
  border-radius: 3px;
  border: 1px solid #e0e0e0;
  border-left: 6px solid #333;
  padding: 10px 10px 10px 30px;
}

.markdown-body .admonition table {
  color: #333;
}

.markdown-body .admonition p {
  padding: 0;
}

.markdown-body .admonition-title {
  font-weight: bold;
  margin: 0;
}

.markdown-body .admonition>.admonition-title {
  color: #333;
}

.markdown-body .attention>.admonition-title {
  color: #a6d796;
}

.markdown-body .caution>.admonition-title {
  color: #d7a796;
}

.markdown-body .hint>.admonition-title {
  color: #96c6d7;
}

.markdown-body .danger>.admonition-title {
  color: #c25f77;
}

.markdown-body .question>.admonition-title {
  color: #96a6d7;
}

.markdown-body .note>.admonition-title {
  color: #d7c896;
}

.markdown-body .admonition:before,
.markdown-body .attention:before,
.markdown-body .caution:before,
.markdown-body .hint:before,
.markdown-body .danger:before,
.markdown-body .question:before,
.markdown-body .note:before {
  font: normal normal 16px fontawesome-mini;
  -moz-osx-font-smoothing: grayscale;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  line-height: 1.5;
  color: #333;
  position: absolute;
  left: 0;
  top: 0;
  padding-top: 10px;
  padding-left: 10px;
}

.markdown-body .admonition:before {
  content: "\f056\00a0";
  color: 333;
}

.markdown-body .attention:before {
  content: "\f058\00a0";
  color: #a6d796;
}

.markdown-body .caution:before {
  content: "\f06a\00a0";
  color: #d7a796;
}

.markdown-body .hint:before {
  content: "\f05a\00a0";
  color: #96c6d7;
}

.markdown-body .danger:before {
  content: "\f057\00a0";
  color: #c25f77;
}

.markdown-body .question:before {
  content: "\f059\00a0";
  color: #96a6d7;
}

.markdown-body .note:before {
  content: "\f040\00a0";
  color: #d7c896;
}

.markdown-body .admonition::after {
  content: normal;
}

.markdown-body .attention {
  border-left: 6px solid #a6d796;
}

.markdown-body .caution {
  border-left: 6px solid #d7a796;
}

.markdown-body .hint {
  border-left: 6px solid #96c6d7;
}

.markdown-body .danger {
  border-left: 6px solid #c25f77;
}

.markdown-body .question {
  border-left: 6px solid #96a6d7;
}

.markdown-body .note {
  border-left: 6px solid #d7c896;
}

.markdown-body .admonition>*:first-child {
  margin-top: 0 !important;
}

.markdown-body .admonition>*:last-child {
  margin-bottom: 0 !important;
}

/* progress bar*/
.markdown-body .progress {
  display: block;
  width: 300px;
  margin: 10px 0;
  height: 24px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
  background-color: #ededed;
  position: relative;
  box-shadow: inset -1px 1px 3px rgba(0, 0, 0, .1);
}

.markdown-body .progress-label {
  position: absolute;
  text-align: center;
  font-weight: bold;
  width: 100%; margin: 0;
  line-height: 24px;
  color: #333;
  text-shadow: 1px 1px 0 #fefefe, -1px -1px 0 #fefefe, -1px 1px 0 #fefefe, 1px -1px 0 #fefefe, 0 1px 0 #fefefe, 0 -1px 0 #fefefe, 1px 0 0 #fefefe, -1px 0 0 #fefefe, 1px 1px 2px #000;
  -webkit-font-smoothing: antialiased !important;
  white-space: nowrap;
  overflow: hidden;
}

.markdown-body .progress-bar {
  height: 24px;
  float: left;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
  background-color: #96c6d7;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -1px 0 rgba(0, 0, 0, .1);
  background-size: 30px 30px;
  background-image: -webkit-linear-gradient(
    135deg, rgba(255, 255, 255, .4) 27%,
    transparent 27%,
    transparent 52%, rgba(255, 255, 255, .4) 52%,
    rgba(255, 255, 255, .4) 77%,
    transparent 77%, transparent
  );
  background-image: -moz-linear-gradient(
    135deg,
    rgba(255, 255, 255, .4) 27%, transparent 27%,
    transparent 52%, rgba(255, 255, 255, .4) 52%,
    rgba(255, 255, 255, .4) 77%, transparent 77%,
    transparent
  );
  background-image: -ms-linear-gradient(
    135deg,
    rgba(255, 255, 255, .4) 27%, transparent 27%,
    transparent 52%, rgba(255, 255, 255, .4) 52%,
    rgba(255, 255, 255, .4) 77%, transparent 77%,
    transparent
  );
  background-image: -o-linear-gradient(
    135deg,
    rgba(255, 255, 255, .4) 27%, transparent 27%,
    transparent 52%, rgba(255, 255, 255, .4) 52%,
    rgba(255, 255, 255, .4) 77%, transparent 77%,
    transparent
  );
  background-image: linear-gradient(
    135deg,
    rgba(255, 255, 255, .4) 27%, transparent 27%,
    transparent 52%, rgba(255, 255, 255, .4) 52%,
    rgba(255, 255, 255, .4) 77%, transparent 77%,
    transparent
  );
}

.markdown-body .progress-100plus .progress-bar {
  background-color: #a6d796;
}

.markdown-body .progress-80plus .progress-bar {
  background-color: #c6d796;
}

.markdown-body .progress-60plus .progress-bar {
  background-color: #d7c896;
}

.markdown-body .progress-40plus .progress-bar {
  background-color: #d7a796;
}

.markdown-body .progress-20plus .progress-bar {
  background-color: #d796a6;
}

.markdown-body .progress-0plus .progress-bar {
  background-color: #c25f77;
}

.markdown-body .candystripe-animate .progress-bar{
  -webkit-animation: animate-stripes 3s linear infinite;
  -moz-animation: animate-stripes 3s linear infinite;
  animation: animate-stripes 3s linear infinite;
}

@-webkit-keyframes animate-stripes {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 60px 0;
  }
}

@-moz-keyframes animate-stripes {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 60px 0;
  }
}

@keyframes animate-stripes {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 60px 0;
  }
}

.markdown-body .gloss .progress-bar {
  box-shadow:
    inset 0 4px 12px rgba(255, 255, 255, .7),
    inset 0 -12px 0 rgba(0, 0, 0, .05);
}

/* Multimarkdown Critic Blocks */
.markdown-body .critic_mark {
  background: #ff0;
}

.markdown-body .critic_delete {
  color: #c82829;
  text-decoration: line-through;
}

.markdown-body .critic_insert {
  color: #718c00 ;
  text-decoration: underline;
}

.markdown-body .critic_comment {
  color: #8e908c;
  font-style: italic;
}

.markdown-body .headeranchor {
  font: normal normal 16px octicons-anchor;
  line-height: 1;
  display: inline-block;
  text-decoration: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.headeranchor:before {
  content: '\f05c';
}

.markdown-body .task-list-item {
  list-style-type: none;
}

.markdown-body .task-list-item+.task-list-item {
  margin-top: 3px;
}

.markdown-body .task-list-item input {
  margin: 0 4px 0.25em -20px;
  vertical-align: middle;
}

/* Media */
@media only screen and (min-width: 480px) {
  .markdown-body {
    font-size:14px;
  }
}

@media only screen and (min-width: 768px) {
  .markdown-body {
    font-size:16px;
  }
}

@media print {
  .markdown-body * {
    background: transparent !important;
    color: black !important;
    filter:none !important;
    -ms-filter: none !important;
  }

  .markdown-body {
    font-size:12pt;
    max-width:100%;
    outline:none;
    border: 0;
  }

  .markdown-body a,
  .markdown-body a:visited {
    text-decoration: underline;
  }

  .markdown-body .headeranchor-link {
    display: none;
  }

  .markdown-body a[href]:after {
    content: " (" attr(href) ")";
  }

  .markdown-body abbr[title]:after {
    content: " (" attr(title) ")";
  }

  .markdown-body .ir a:after,
  .markdown-body a[href^="javascript:"]:after,
  .markdown-body a[href^="#"]:after {
    content: "";
  }

  .markdown-body pre {
    white-space: pre;
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  .markdown-body pre,
  .markdown-body blockquote {
    border: 1px solid #999;
    padding-right: 1em;
    page-break-inside: avoid;
  }

  .markdown-body .progress,
  .markdown-body .progress-bar {
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
  }

  .markdown-body .progress {
    border: 1px solid #ddd;
  }

  .markdown-body .progress-bar {
    height: 22px;
    border-right: 1px solid #ddd;
  }

  .markdown-body tr,
  .markdown-body img {
    page-break-inside: avoid;
  }

  .markdown-body img {
    max-width: 100% !important;
  }

  .markdown-body p,
  .markdown-body h2,
  .markdown-body h3 {
    orphans: 3;
    widows: 3;
  }

  .markdown-body h2,
  .markdown-body h3 {
    page-break-after: avoid;
  }
}
</style><title>mySQL</title></head><body><article class="markdown-body"><div class="toc">
<ul>
<li><a href="#mysql">MySQL</a><ul>
<li><a href="#_1">什么是数据库</a><ul>
<li><a href="#_2">结构化的数据</a></li>
</ul>
</li>
<li><a href="#_3">关系型数据库</a><ul>
<li><a href="#table">表（table）:</a></li>
</ul>
</li>
<li><a href="#mysql_1">MySql的特点:</a></li>
<li><a href="#_4">数据库操作</a><ul>
<li><a href="#_5">表操作(了解)</a></li>
<li><a href="#navicat">Navicat操作数据库</a></li>
<li><a href="#_6">数据操作（重点）</a></li>
</ul>
</li>
<li><a href="#php">php操作数据库</a><ul>
<li><a href="#mysql_2">连接 MySQL</a></li>
<li><a href="#insert-into">插入数据INSERT INTO</a></li>
<li><a href="#_7">读取数据</a></li>
<li><a href="#mysql_3">mySQL语句返回值</a></li>
</ul>
</li>
<li><a href="#_8">下节预习</a></li>
</ul>
</li>
</ul>
</div>
<h1 id="mysql"><a name="user-content-mysql" href="#mysql" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>MySQL</h1>
<h2 id="_1"><a name="user-content-_1" href="#_1" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>什么是数据库</h2>
<p>数据库（Database）是按照数据结构来组织、存储和管理数据的仓库</p>
<p><strong>热门数据库</strong></p>
<ul>
<li>Oracle</li>
<li>SQLServer</li>
<li>MySQL</li>
<li>MongoDB</li>
<li>SQLite</li>
<li>access</li>
<li>DB2</li>
</ul>
<h3 id="_2"><a name="user-content-_2" href="#_2" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>结构化的数据</h3>
<p><img alt="Alt text" src="img/sql1.png" title="Optional title" /></p>
<p><strong>仔细阅读上面这段话，如果让你提取这段文字的中心意思，你能做到吗？</strong></p>
<p>我相信对一个正常人来说都不是难事。可是，这段话如果交给计算机去处理呢？ 计算机没有人类的思维，这件事对它来讲恐怕就太难了，因此，有时候我们才需要将数据结构化。</p>
<p>结构化的数据是什么样子呢？以上面那段话为例，我们将它的信息提取出来，以表格的形式展现：</p>
<table>
<thead>
<tr>
<th>姓名</th>
<th>年龄</th>
<th>性别</th>
<th>性格</th>
<th>所在地</th>
<th>毕业院校</th>
<th>专业</th>
</tr>
</thead>
<tbody>
<tr>
<td>lemon</td>
<td>20</td>
<td>女</td>
<td>乐观</td>
<td>广州</td>
<td>清华</td>
<td>前端开发</td>
</tr>
<tr>
<td>laoxie</td>
<td>18</td>
<td>男</td>
<td>积极向上</td>
<td>广州</td>
<td>蓝翔</td>
<td>挖掘机</td>
</tr>
</tbody>
</table>
<blockquote>
<p>这样一来，我们把一段复杂的信息，进行了结构化处理，瞬间显得清爽多了。计算机处理起来也相当方便。 因此，这样的数据，我们就称之为结构化数据，而上面的表格称之为表。</p>
</blockquote>
<h2 id="_3"><a name="user-content-_3" href="#_3" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>关系型数据库</h2>
<p>是建立在关系模型基础上的数据库，复杂的数据库表与表之间必定存在某种联系</p>
<table>
<thead>
<tr>
<th>姓名</th>
<th>身份证</th>
<th>银行卡号</th>
<th>余额</th>
<th>消费记录</th>
</tr>
</thead>
<tbody>
<tr>
<td>老谢</td>
<td>450721199805012611</td>
<td>8888 6968 9898</td>
<td>865424.00</td>
<td>2016.11.1 6000买iphone7, 2016.12.20 5800买note7, 2017.1.1 1665800买飞机</td>
</tr>
</tbody>
</table>
<p>所有的购买记录这样的数据看起来是不是很别扭呢？ 因为它查询起来极不方便。</p>
<p>因此我们把它改造一下（把用户和消费记录分开）：</p>
<table>
<thead>
<tr>
<th>编号</th>
<th>姓名</th>
<th>身份证</th>
<th>银行卡号</th>
<th>余额</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>老谢</td>
<td>450721199805012611</td>
<td>8888 6968 9898</td>
<td>865424.00</td>
</tr>
<tr>
<td>2</td>
<td>蓝梦</td>
<td>460751198007125628</td>
<td>8888 6968 9898</td>
<td>26424.00</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>编号</th>
<th>时间</th>
<th>消费金额</th>
<th>备注</th>
<th>用户编号</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2016.11.1</td>
<td>6000</td>
<td>买iphone7</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2016.12.20</td>
<td>5800</td>
<td>买note7</td>
<td>1</td>
</tr>
<tr>
<td>3</td>
<td>2017.1.1</td>
<td>1665800</td>
<td>买飞机</td>
<td>2</td>
</tr>
</tbody>
</table>
<p>我们把用户账号的信息，和消费记录信息分离开来，通过用户编号进行了关联 既把不同的数据进行了分离，使得查询数据更加方便。同时又保证了它们关系的正确性。 </p>
<p><strong>这就是传统的关系型数据库。</strong> 其中 &lt;用户编号&gt; 我们称之为<strong>外键</strong></p>
<h3 id="table"><a name="user-content-table" href="#table" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>表（table）:</h3>
<p>一个数据库通常包含一个或多个表，一个数据表有一个唯一名称，并有行和列组成。<br />
表(table) 是数据库中一个重要的组成部分, 数据库只是一个框架，数据表才是其实质内容。<br />
<img alt="数据库与表" src="///F://mydoc/kphone/Outline3/Section2/7.0/22mysql/doc/img/img1.png" title="数据库与表" /></p>
<ul>
<li>表结构</li>
</ul>
<table>
    <thead>
        <tr>
            <th>身份ID</th>
            <th>姓名</th>
            <th>性别</th>
            <th>年龄</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>刘备</td>
            <td>男</td>
            <td>40</td>
        </tr>
        <tr>
            <td>2</td>
            <td>关羽</td>
            <td>男</td>
            <td>36</td>
        </tr>
        <tr>
            <td>3</td>
            <td>貂蝉</td>
            <td>女</td>
            <td>18</td>
        </tr>
        <tr>
            <td>4</td>
            <td>张飞</td>
            <td>男</td>
            <td>30</td>
        </tr>
    </tbody>
</table>

<h2 id="mysql_1"><a name="user-content-mysql_1" href="#mysql_1" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>MySql的特点:</h2>
<blockquote>
<p>MySql是目前最流行的关系型数据库管理系统，由瑞典MySQL AB公司开发，目前属于Oracle公司</p>
</blockquote>
<ul>
<li>MySQL是开源的，免费。</li>
<li>MySQL支持标准的SQL数据语句</li>
<li>MySQL可以允许于多个系统上，并且支持多种语言。这些编程语言包括C、C++、Python、Java、Perl、PHP、Eiffel、NodeJS、Ruby和Tcl等。</li>
<li>MySQL对PHP有很好的支持，PHP是目前最流行的Web开发语言。</li>
<li>MySQL支持大型数据库，支持5000万条记录的数据仓库，32位系统表文件最大可支持4GB，64位系统支持最大的表文件为8TB。</li>
</ul>
<h2 id="_4"><a name="user-content-_4" href="#_4" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>数据库操作</h2>
<h3 id="_5"><a name="user-content-_5" href="#_5" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>表操作(了解)</h3>
<ul>
<li>
<p>连接数据库<br />
格式：<code>mysql -h主机地址 -u用户名 -p用户密码</code></p>
</li>
<li>
<p>显示所有数据库<br />
格式：<code>show databases;</code></p>
</li>
<li>
<p>创建数据库<br />
格式：<code>create database &lt;数据库名&gt;;</code></p>
</li>
<li>
<p>使用数据库<br />
格式：<code>use &lt;数据库名&gt;;</code></p>
</li>
<li>
<p>显示当前数据库所有表<br />
格式：<code>show tables;</code></p>
</li>
<li>
<p>创建数据表<br />
格式：<code>create table &lt;表名&gt; (&lt;字段名1&gt; &lt;类型1&gt; [,..&lt;字段名n&gt; &lt;类型n&gt;]);</code><br />
<pre><code>    create table MyGuests (
    id int(6) unsigned auto_increment primary key, 
    firstname varchar(30) not null,
    lastname varchar(30) not null,
    email varchar(50),
    reg_date timestamp
    )
</code></pre><br />
以上创建一个名为 &ldquo;MyGuests&rdquo; 的表，包含5个列： &ldquo;id&rdquo;, &ldquo;firstname&rdquo;, &ldquo;lastname&rdquo;, &ldquo;email&rdquo; 和 &ldquo;reg_date&rdquo;，参数如下：</p>
<ul>
<li>数据类型: <ul>
<li>INT(整型), </li>
<li>FLOAT(浮点), </li>
<li>CHAR(固定长度字符串), </li>
<li>VARCHAR(可变长度字符串), </li>
<li>BLOB(二进制), </li>
<li>TEXT(字符串)</li>
<li>TIMESTAMP(时间戳)</li>
</ul>
</li>
<li>列的其他属性<ul>
<li>NOT NULL - 每一行都必须含有值（不能为空），null 值是不允许的。</li>
<li>DEFAULT value - 设置默认值</li>
<li>UNSIGNED - 使用无符号数值类型，0 及正数</li>
<li>AUTO_INCREMENT - 设置 MySQL 字段的值在新增记录时每次自动增长 1</li>
<li>PRIMARY KEY - 设置数据表中每条记录的唯一标识。 通常列的 PRIMARY KEY 设置为 ID 数值，与 AUTO_INCREMENT 一起使用。</li>
</ul>
</li>
</ul>
</li>
<li>
<p>删除表：<br />
格式：<code>drop table &lt;表名&gt;;</code><br />
<pre><code>drop table MyGuests;
drop table if exists MyGuests
</code></pre></p>
</li>
<li>
<p>查询表结构：<br />
<code>desc MyGuests</code></p>
</li>
<li>
<p>修改表名。<br />
<code>rename table MyClass to YouClass;</code></p>
</li>
<li>
<p>增加字段<br />
<code>alter table MyGuests add sku_id bigint(20) unsigned DEFAULT NULL COMMENT '商品销售码';</code></p>
</li>
<li>
<p>复制表结构：<br />
<code>create table table1 like table;</code></p>
</li>
</ul>
<h3 id="navicat"><a name="user-content-navicat" href="#navicat" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Navicat操作数据库</h3>
<ul>
<li>数据库创建</li>
<li>表创建</li>
<li>增删查改（CRUD）</li>
<li>数据导入<ul>
<li>json</li>
<li>excel</li>
</ul>
</li>
</ul>
<h3 id="_6"><a name="user-content-_6" href="#_6" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>数据操作（重点）</h3>
<ul>
<li>
<p>插入数据<br />
格式：<code>insert into &lt;表名&gt; [(&lt;字段名1&gt;[,..&lt;字段名n &gt; ])] values ( 值1 )[, (值n )];</code><br />
<pre><code>//单条数据
insert into MyGuests (firstname, lastname, email)
values ('John', 'Doe', 'john@example.com')
</code></pre></p>
</li>
<li>
<p>删除表数据<br />
格式：delete from 表名 where 表达式<br />
<pre><code>//删除MyGuests表中id为1的数据
DELETE FROM MyGuests where id=1;

//删除所有数据
DELETE FROM MyGuests

</code></pre></p>
</li>
<li>
<p>查询表中的数据<br />
格式： select &lt;字段1, 字段2, &hellip;&gt; from &lt; 表名 &gt; where &lt; 表达式 &gt;;<br />
<pre><code>//查看表 MyGuests 中所有数据
select * from MyGuests;

//查看表 MyGuests 中前10行数据：
select * from MyGuests order by id limit 0,10;
</code></pre></p>
<blockquote>
<p>select一般配合where使用，以查询更精确更复杂的数据。</p>
</blockquote>
</li>
<li>
<p>修改表中的数据。<br />
格式：update 表名 set 字段=新值,… where 条件;<br />
<pre><code>update MyGuests set name='Mary' where id=1;
</code></pre></p>
</li>
<li>
<p>条件控制语句</p>
<ul>
<li>WHERE 语句：<blockquote>
<p>SELECT * FROM tb_name WHERE id=3;</p>
</blockquote>
</li>
<li>相关条件控制符： <ul>
<li>=、&gt;、&lt;、&lt;&gt;、IN(1,2,3......)、BETWEEN a AND b</li>
<li>AND、OR、NOT</li>
<li>LIKE用法中      <ul>
<li>%  匹配任意、 </li>
<li>_  匹配一个字符（可以是汉字）</li>
</ul>
</li>
</ul>
</li>
<li>LIMIT idx,qty：数量控制<ul>
<li>SELECT * FROM goods LIMIT 2,5</li>
</ul>
</li>
<li>IS NULL 空值检测</li>
<li>排序ORDER BY<ul>
<li>asc 升序（默认）</li>
<li>desc 降序</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="php"><a name="user-content-php" href="#php" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>php操作数据库</h2>
<h3 id="mysql_2"><a name="user-content-mysql_2" href="#mysql_2" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>连接 MySQL</h3>
<p>PHP 5 及以上版本建议使用以下方式连接 MySQL :</p>
<ul>
<li>
<p>MySQLi extension (&ldquo;i&rdquo; 意为 improved)<br />
安装：Linux 和 Windows: 在 php5 mysql 包安装时 MySQLi 扩展多数情况下是自动安装<br />
<pre><code class="php">    &lt;?php
        $servername = &quot;localhost&quot;;
        $username = &quot;username&quot;;
        $password = &quot;password&quot;;
        $dbname = 'user';

        // 创建连接
        $conn = new mysqli($servername, $username, $password, $dbname);

        // 检测连接
        if ($conn-&gt;connect_error) {
            die(&quot;连接失败: &quot; . $conn-&gt;connect_error);
        } 

        //查询前设置编码，防止输出乱码
        $conn-&gt;set_charset('utf8');

        echo &quot;连接成功&quot;;
    ?&gt;
</code></pre></p>
</li>
<li>
<p>执行sql语句查询结果集<br />
<pre><code class="php">    //编写sql语句
    $sql = 'select * from student';

    //获取查询结果集
    $result = $conn-&gt;query($sql);

    //使用查询结果集
    //得到数组
    $row = $result-&gt;fetch_all(MYSQLI_ASSOC);

    //释放查询结果集，避免资源浪费
    $result-&gt;close();

    //把结果输出到前台
    echo json_encode($row);

    // 关闭数据库，避免资源浪费
    $conn-&gt;close();

</code></pre></p>
</li>
</ul>
<h3 id="insert-into"><a name="user-content-insert-into" href="#insert-into" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>插入数据INSERT INTO</h3>
<ul>
<li>
<p>单条数据<br />
<pre><code class="php">$sql = &quot;INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com')&quot;;

if ($conn-&gt;query($sql)) {
    echo &quot;新记录插入成功&quot;;
} else {
    echo &quot;Error: &quot; . $sql . &quot;&lt;br&gt;&quot; . $conn-&gt;error;
}
</code></pre></p>
</li>
<li>
<p>多条数据<br />
<pre><code class="php">    $sql = &quot;INSERT INTO `projects` (`name`, `url`, `description`) VALUES &quot;;
    foreach ($projects as $item) {
        $sql .= &quot;('$item',NULL, NULL),&quot;;
    }
    $sql = substr($sql,0,-1);

    if ($conn-&gt;query($sql)) {
        echo &quot;新记录插入成功&quot;;
    } else {
        echo &quot;Error: &quot; . $sql . &quot;&lt;br&gt;&quot; . $conn-&gt;error;
    }
</code></pre></p>
</li>
</ul>
<h3 id="_7"><a name="user-content-_7" href="#_7" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>读取数据</h3>
<p>SELECT&hellip;FROM，得到查询结果集</p>
<ul>
<li>num_rows ：结果集中的数量，用于判断是否查询到结果</li>
<li>fetch_all(MYSQLI_ASSOC)   得到所有结果</li>
<li>fetch_assoc()             得到第一个结果</li>
<li>fetch_row()</li>
</ul>
<pre><code class="php">    $sql = &quot;SELECT id, firstname, lastname FROM MyGuests&quot;;
    $result = $conn-&gt;query($sql);

    if ($result-&gt;num_rows &gt; 0) {
        // 输出每行数据
        while($row = $result-&gt;fetch_assoc()) {
            echo &quot;&lt;br&gt; id: &quot;. $row[&quot;id&quot;]. &quot; - Name: &quot;. $row[&quot;firstname&quot;]. &quot; &quot; . $row[&quot;lastname&quot;];
        }
    } else {
        echo &quot;0 个结果&quot;;
    }
</code></pre>

<h3 id="mysql_3"><a name="user-content-mysql_3" href="#mysql_3" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>mySQL语句返回值</h3>
<ul>
<li>返回布尔值<ul>
<li>insert</li>
<li>update</li>
<li>delete</li>
</ul>
</li>
<li>返回查询结果集<ul>
<li>select语句</li>
</ul>
</li>
</ul>
<hr />
<h2 id="_8"><a name="user-content-_8" href="#_8" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>下节预习</h2>
<ul>
<li>Ajax</li>
</ul></article></body></html>